package me.softwareengineer.guice.rendering.domain;

import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.OnWordEvent;

/**
 * Represents a word in DOM tree.
 * 
 * @author yad.tahir
 * 
 * <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 */
public final class WordElement extends Element {

	/**
	 * Holds word value
	 */
	private final String word;


	/**
	 * Creates WordElement with empty Word
	 */
	public WordElement() {
		word = null;
	}

	/**
	 * Creates the word element
	 * 
	 * @param word
	 *            the word value
	 */
	public WordElement(String word) {
		
			this.word = word;
		
		
	}

	/**
	 * 
	 * @return the word wrapped by the element
	 * <p>
	 * This property is immutable and thread-safe
	 * </p>
	 */
	public String getWord() {
		
	
			
		return this.word;

	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see Element#render(Listener)
	 */
	@Override
	public void render(Listener listener) {
		OnWordEvent e = new OnWordEvent(getWord());
		listener.onEvent(e);
	}

	 
}
